extends Node2D

signal plant_select(str: String)

@export var plant_card: PackedScene
var sun_point: int = 50

func get_sun_point():
	return sun_point

func set_sun_point(val: int):
	sun_point = val;
	$Label.text = "{0}".format([sun_point])
	pass

# Called when the node enters the scene tree for the first time.
func _ready():
	#$CardPeaShooter.set_plant_card("peashooter")
	addPlant("peashooter", 0)
	addPlant("sunflower", 1)
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass


func _on_card_template_plant_select(str: String):
	plant_select.emit(str)
	pass # Replace with function body.

func addPlant(plant_name: String, i: int):
	var plant = plant_card.instantiate()
	plant.set_plant_card(plant_name)
	plant.position = Vector2(80+54*i, 8)
	plant.plant_select.connect(_on_card_template_plant_select)
	add_child(plant)
	pass
